<template>
  <div>
    <textarea
      name=""
      id=""
      class="textarea"
      maxlength="200"
      placeholder="请留下您的宝贵建议或意见..."
      v-model="value"
    ></textarea>
    <div class="maxlength">{{ value.length }}/200</div>
    <div class="confirm" @click="addFeedback">提交</div>
  </div>
</template>
<script>
import { addFeedback } from "@/api/api";
export default {
  data() {
    return {
      value: "",
    };
  },
  methods: {
    addFeedback() {
      addFeedback({
        type: 1,
        content: this.value,
      }).then((res) => {
        if (res.code == 200) {
          alert("提交成功");
          setTimeout(() => {
            this.$router.go(-1);
          }, 2000);
        }
      });
    },
  },
};
</script>
<style scoped>
.textarea {
  display: block;
  width: calc(100% - 4rem);
  margin: 0 1rem;
  padding: 1rem;
  height: 9.375rem;
  background: #f7fafd;
  border-radius: 0.75rem;
  border: none;
  outline: none;
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.maxlength {
  width: 93%;
  text-align: right;
  font-size: 0.875rem;
  color: #a4adbe;
  position: relative;
  top: -1.875rem;
}
.confirm {
  width: calc(100% - 2rem);
  margin: 3.125rem 1rem;
  height: 2.75rem;
  background: linear-gradient(90deg, #448eff 0%, #66a3ff 100%);
  border-radius: 0.1875rem;
  text-align: center;
  font-size: 1.125rem;
  font-weight: bold;
  color: #fff;
  line-height: 2.75rem;
}
</style>